﻿<%@ Page Title="Add Stock Transfer" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="str_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
    .auto-style6 {
        width: 260px;
    }
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
       <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:Panel ID="ParentPanel" runat="server">
                <h2>Stock Transfer Form</h2>
                <div></div>
                <asp:Label ID="lblParentReturn" runat="server" Font-Italic="True"></asp:Label>
                <table style="width:100%;">
                    <tr>
                        <td class="auto-style6">
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td class="auto-style6">
                            <asp:Panel ID="companypanel" runat="server">
                                <asp:RadioButton ID="RadioButton1" runat="server" Checked="True" GroupName="Companygrp" Text="Kenny Rogers" />
                                <br />
                                <asp:RadioButton ID="RadioButton2" runat="server" GroupName="Companygrp" Text="Seattles Best" />
                                <br />
                                <asp:RadioButton ID="RadioButton3" runat="server" GroupName="Companygrp" Text="Kanto Grill" />
                            </asp:Panel>
                        </td>
                        <td>Date Filed:<asp:TextBox ID="CalDateFiled" runat="server" TextMode="Date"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="CalDateFiled" Display="None" ErrorMessage="* Date Filed"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style6">STR Number :
                            <asp:TextBox ID="txtStr_no" runat="server" TextMode="Number">0</asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtStr_no" Display="None" ErrorMessage="* STR Number"></asp:RequiredFieldValidator>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="auto-style6">Transfer From:<asp:TextBox ID="txtTransfer_from" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTransfer_from" Display="None" ErrorMessage="* Transfer From"></asp:RequiredFieldValidator>
                        </td>
                        <td>Transfer To:&nbsp;&nbsp; <asp:TextBox ID="txtTransfer_To" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtTransfer_To" Display="None" ErrorMessage="* Transfer To"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style6">Prepared By:&nbsp;&nbsp; <asp:TextBox ID="txtPrepared_by" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtPrepared_by" Display="None" ErrorMessage="* Prepared By"></asp:RequiredFieldValidator>
                        </td>
                        <td>Approved By:<asp:TextBox ID="txtApproved_by" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtApproved_by" Display="None" ErrorMessage="* Approved By"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style6">Recieved By:&nbsp;&nbsp; <asp:TextBox ID="txt_Recievedby" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txt_Recievedby" Display="None" ErrorMessage="* Recieved By"></asp:RequiredFieldValidator>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="auto-style6" >
                            <asp:Button ID="Button2" runat="server" Text="Save Info" Height="26px" Width="78px" CssClass="button" />
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </asp:Panel>
            <asp:SqlDataSource ID="sqlparent" runat="server" ConnectionString="<%$ ConnectionStrings:Management_Info_SysConnectionString %>" DeleteCommand="DELETE FROM str_parents WHERE (str_no = @str_no)" InsertCommand="INSERT INTO [str_parents] ([str_no], [company], [date_filed], [transfer_from], [transfer_to], [prepared_by], [approved_by], [recieved_by], [time_stamp], [UploadedBy]) VALUES (@str_no, @company, @date_filed, @transfer_from, @transfer_to, @prepared_by, @approved_by, @recieved_by, @time_stamp, @UploadedBy)" SelectCommand="SELECT * FROM [str_parents]" UpdateCommand="UPDATE [str_parents] SET [str_no] = @str_no, [company] = @company, [date_filed] = @date_filed, [transfer_from] = @transfer_from, [transfer_to] = @transfer_to, [prepared_by] = @prepared_by, [approved_by] = @approved_by, [recieved_by] = @recieved_by, [time_stamp] = @time_stamp, [UploadedBy] = @UploadedBy WHERE [str_key] = @str_key">
                <DeleteParameters>
                    <asp:ControlParameter ControlID="txtStr_no" Name="str_no" PropertyName="Text" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:ControlParameter ControlID="txtStr_no" Name="str_no" PropertyName="Text" Type="Int64" />
                    <asp:SessionParameter DefaultValue="Kenny Rogers" Name="company" SessionField="sel_company" Type="String" />
                    <asp:ControlParameter ControlID="CalDateFiled" Name="date_filed" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txtTransfer_from" Name="transfer_from" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txtTransfer_To" Name="transfer_to" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txtPrepared_by" Name="prepared_by" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txtApproved_by" Name="approved_by" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txt_Recievedby" Name="recieved_by" PropertyName="Text" Type="String" />
                    <asp:SessionParameter DefaultValue="" Name="time_stamp" SessionField="time_stamp" Type="String" />
                    <asp:SessionParameter Name="UploadedBy" SessionField="agent" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="str_no" Type="Int64" />
                    <asp:Parameter Name="company" Type="String" />
                    <asp:Parameter Name="date_filed" Type="String" />
                    <asp:Parameter Name="transfer_from" Type="String" />
                    <asp:Parameter Name="transfer_to" Type="String" />
                    <asp:Parameter Name="prepared_by" Type="String" />
                    <asp:Parameter Name="approved_by" Type="String" />
                    <asp:Parameter Name="recieved_by" Type="String" />
                    <asp:Parameter Name="time_stamp" Type="String" />
                    <asp:Parameter Name="UploadedBy" Type="String" />
                    <asp:Parameter Name="str_key" Type="Int64" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="sqlParentCheck" runat="server" ConnectionString="<%$ ConnectionStrings:Management_Info_SysConnectionString %>" SelectCommand="SELECT * FROM [str_parents] WHERE ([str_no] = @str_no)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="txtStr_no" Name="str_no" PropertyName="Text" Type="Int64" />
                </SelectParameters>
            </asp:SqlDataSource>
            <hr />
            <br />

            <asp:Panel ID="ItemPanel" runat="server" Enabled="False">
                <h3>Stock Transfer Item</h3>
                <table style="width:98%;">
                    <tr>
                        <td>Qty</td>
                        <td>Unit</td>
                        <td>SKU</td>
                        <td>Description</td>
                        <td>Unit Price</td>
                        <td>Total Price</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            <asp:TextBox ID="txtQty" runat="server" CssClass="QtyClass" TextMode="Number"></asp:TextBox>
                        </td>
                        <td>
                            <asp:DropDownList ID="listUnit" runat="server" AutoPostBack="True">
                                <asp:ListItem>PC</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td>
                            <asp:TextBox ID="txtSKU" runat="server" CssClass="FulltextboxSize"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="txtDescription" runat="server" CssClass="FulltextboxSize"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="txtUnitPrice" runat="server" AutoPostBack="True"  CssClass="QtyClass" TextMode="Number"></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="txtTotalPrice" runat="server" ReadOnly="True" CssClass="FulltextboxSize"></asp:TextBox>
                        </td>
                        <td>
                            <asp:Button ID="Button3" runat="server" Text="Add" />
                            <asp:Label ID="returnItem" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="qtyReturn" runat="server"></asp:Label>
                        </td>
                        <td>&nbsp;</td>
                        <td>
                            <asp:Label ID="SKUReturn" runat="server"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="DescReturn" runat="server"></asp:Label>
                        </td>
                        <td>
                            <asp:Label ID="UnitPriceReturn" runat="server"></asp:Label>
                        </td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
                <asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="str_item_key" DataSourceID="SqlItems" ForeColor="#333333" GridLines="None">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                        <asp:BoundField DataField="str_item_key" HeaderText="str_item_key" InsertVisible="False" ReadOnly="True" SortExpression="str_item_key" Visible="False" />
                        <asp:BoundField DataField="str_no" HeaderText="str_no" SortExpression="str_no" Visible="False" />
                        <asp:BoundField DataField="qty" HeaderText="Qty" SortExpression="qty" />
                        <asp:BoundField DataField="Unit" HeaderText="Unit" SortExpression="unit" />
                        <asp:BoundField DataField="SKU" HeaderText="SKU" SortExpression="sku" />
                        <asp:BoundField DataField="description" HeaderText="Description" SortExpression="description" />
                        <asp:BoundField DataField="unit_price" HeaderText="Unit Price" SortExpression="unit_price" />
                        <asp:BoundField DataField="total" HeaderText="Total" SortExpression="total" />
                        <asp:BoundField DataField="time_stamp" HeaderText="time_stamp" SortExpression="time_stamp" Visible="False" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <br />
            </asp:Panel>
            <br />
            <br />
            <table style="width:100%;">
                <tr>
                    <td>
                        <asp:Button ID="Button4" runat="server" Enabled="False" Text="Cancel" />
                        <asp:Button ID="Button1" runat="server" Text="Close" />
                        <asp:Label ID="lblAllReturn" runat="server"></asp:Label>
                    </td>
                </tr>
            </table>
            <br />
            <asp:SqlDataSource ID="SqlItems" runat="server" ConnectionString="<%$ ConnectionStrings:Management_Info_SysConnectionString %>" DeleteCommand="DELETE FROM str_items_ WHERE (str_no = @str_no)" InsertCommand="INSERT INTO [str_items_] ([str_no], [qty], [unit], [sku], [description], [unit_price], [total], [time_stamp]) VALUES (@str_no, @qty, @unit, @sku, @description, @unit_price, @total, @time_stamp)" SelectCommand="SELECT str_item_key, str_no, qty, unit, sku, description, unit_price, total, time_stamp FROM str_items_ WHERE (str_no = @str_no)" UpdateCommand="UPDATE [str_items_] SET [str_no] = @str_no, [qty] = @qty, [unit] = @unit, [sku] = @sku, [description] = @description, [unit_price] = @unit_price, [total] = @total, [time_stamp] = @time_stamp WHERE [str_item_key] = @str_item_key">
                <DeleteParameters>
                    <asp:ControlParameter ControlID="txtStr_no" Name="str_no" PropertyName="Text" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:ControlParameter ControlID="txtStr_no" Name="str_no" PropertyName="Text" Type="Int64" />
                    <asp:ControlParameter ControlID="txtQty" Name="qty" PropertyName="Text" Type="Int64" />
                    <asp:ControlParameter ControlID="txtUnitPrice" Name="unit" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txtSKU" Name="sku" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txtDescription" Name="description" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="txtUnitPrice" Name="unit_price" PropertyName="Text" Type="Int64" />
                    <asp:SessionParameter Name="total" SessionField="TotalPrice" Type="Int64" />
                    <asp:SessionParameter DefaultValue="" Name="time_stamp" SessionField="time_stamp" Type="String" />
                </InsertParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="txtStr_no" Name="str_no" PropertyName="Text" Type="Int64" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="str_no" Type="Int64" />
                    <asp:Parameter Name="qty" Type="Int64" />
                    <asp:Parameter Name="unit" Type="String" />
                    <asp:Parameter Name="sku" Type="String" />
                    <asp:Parameter Name="description" Type="String" />
                    <asp:Parameter Name="unit_price" Type="Int64" />
                    <asp:Parameter Name="total" Type="Int64" />
                    <asp:Parameter Name="time_stamp" Type="String" />
                    <asp:Parameter Name="str_item_key" Type="Int64" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <br />
            <br />
            <br />
            <br />
        </ContentTemplate>
    </asp:UpdatePanel>
    </asp:Content>

